<?php 
    echo $this->Html->script(array('jquery-1.8.2.min'));                  
    $subsite_id = -1;    
    $sub_menu = null;
    $site_current = Configure::read('App.themes.site_current');
    if(!empty($site_current)){
        $subsite_id = $site_current['sub_sites']['id'];   
        $sub_menu = ClassRegistry::init('Node.NodeType')->find('all',array(
            'locale'=>true,           
            'conditions'=>array('NodeType.sub_site'=>$subsite_id,'NodeType.menu_child'=>1),
            'order'=>'NodeType.created asc'
        ));                             
    }   
?>
<div class="wd-controlHeader">
    <div class="wd-above">
        <?php if(!empty($sub_menu)):$i=1;$href = "#";$classFirst = '';?>
            <ul class="wd-link-other">
                <?php foreach($sub_menu as $k=>$v):?>
                <?php if($i==1){$classFirst = "linkFirst";}?>
                <?php if(!empty($v['NodeType']['action'])){
                    $href = array('plugin'=>'View','controller'=>'View','action'=>$v['NodeType']['action']);
                }
                ?>                                
                    <li class="<?php echo $classFirst;?>"><a href="<?php echo $this->Html->url($href);?>"><?php echo $v['NodeType']['name'];?></a></li>                    
                <?php $i++;$classFirst = '';$href="#";endforeach;?>
            </ul>   
        <?php endif;?>
    <?php 
        $config_language = Configure::read('App.Languages.config_language');
        if(!empty($config_language)){           
           $config_language = Set::combine($config_language,'{n}.config_language.prefix','{n}.config_language.name'); 
        }        
    ?>     
    <div class="wd-language-switcher">
            <?php 
                $url = $_SERVER['REQUEST_URI'];                
                $langCode = substr($url,1,3);                                
                $languageCurrent = Configure::read('App.Languages.languageCurrent');                
                $prefix = $languageCurrent['config_language']['prefix'];
                if(empty($langCode)){
                  $langCode = $prefix;   
                }                                                                           
            ?>
           <?php echo $this->Form->input('language',array(
                'type'=>'select',
                'div'=>false,
                'label'=>false,
                'class'=>"wd-langue",
                'id'=>'changeLanguage',
                'onchange'=>'swichLanguage()',                
                'options'=>$config_language
            ));?>           
        </div>
    </div>
    <a href="#" class="wd-rss"><i class="iconmuch-rss">&nbsp;</i></a>
    <?php  echo $this->Form->create('Contact', array('url' => array(
                    'plugin'        => 'View',
                    'controller'    => 'View',
                    'action'        => 'search',                                              
                ))); 
    ?> 
    <div id="wd-form-search">
        <fieldset id="wd-header-search">    
            <div class="wd-input">
                <?php
                    echo $this->Form->input('keyword', array(
                        'div' => false,
                        'label' => false,
                        'type' => 'text',
                        'class' => 'input_text placeholder',
                        "placeholder" => __d('default',"Nhập thông tin cần tìm...", true)                    
                    ));
                ?>                
            </div>
            <div class="wd-submit-search">
                <input type="submit" value="<?php echo __d('default','Tìm kiếm');?>"/>
            </div>
        </fieldset>
    </div>
    <?php echo $this->Form->end();?>
</div>
<script language="javascript" type="text/javascript">
       function swichLanguage() {
           var _href = window.location.href;           
           var langCode = '<?php echo $langCode;?>';          
           var prefix = '<?php echo $prefix;?>';                  
           var _val = $('#changeLanguage').val();            
           if(_href.indexOf(langCode)!=-1){
             _href =  _href.replace(langCode,_val); 
             alert(_href);                         
           }else{                
                alert(_href);                        
                return false;              
           }           
           //window.location = _href;                 
        }
</script>